package com.qys.livesMall.shop.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qys.livesMall.shop.dao.H2ShopAdvertInfoDao;
import com.qys.livesMall.shop.mapper.H2ShopAdvertInfoMapper;
import com.qys.livesMall.shop.modal.entity.H2ShopAdvertInfo;
import com.qys.livesMall.shop.service.H2ShopAdvertInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 店铺轮播广告信息 服务实现类
 * </p>
 *
 * @author
 * @since 2023-06-03
 */
@Service
public class H2ShopAdvertInfoDaoImpl extends ServiceImpl<H2ShopAdvertInfoMapper, H2ShopAdvertInfo> implements H2ShopAdvertInfoDao {

    @Override
    public List<H2ShopAdvertInfo> getByShopId(Long shopId, String status) {
        LambdaQueryWrapper<H2ShopAdvertInfo> qw =new LambdaQueryWrapper<>();
        qw.eq(H2ShopAdvertInfo::getShopId,shopId);
        if(status!=null) {
            qw.eq(H2ShopAdvertInfo::getStatus,status);
        }
        return list(qw);
    }

    @Override
    public long countByShopId(Long shopId) {
        LambdaQueryWrapper<H2ShopAdvertInfo> qw =new LambdaQueryWrapper<>();
        qw.eq(H2ShopAdvertInfo::getShopId,shopId);
        return count(qw);
    }
}
